#include "main.h"
#include "CVObject.h"
#include "Functions.h"
#include "Global.h"

CVObject::CVObject() {
	Init(NULL);
	m_objectid=102;
	m_prevpos=V0;
	m_nextpos=V0;
	m_friction=V0;
	m_pSprite=NULL;

	m_pCollider->SetCollisionType(Dynamic);
};

CVObject::CVObject(ENTITY_PARAMS* params, CSprite* _sprite){
	Init(params);
	m_objectid=102;
	m_pSprite=_sprite;
	m_prevpos=m_pos;
	m_nextpos=m_pos;
	m_friction=V0;

	m_pCollider->SetCollisionType(Dynamic);
};
CVObject::~CVObject(){};

void CVObject::Step(CEntityList *_EntList, BYTE _keys[256], DIMOUSESTATE _mouse){
	if(!(m_state & Immovable)){
		Verlet();
		m_pos.x = min(max(m_pos.x, m_halfwidth), LEVEL_WIDTH-m_halfwidth);
		m_pos.y = min(max(m_pos.y, m_halfheight), LEVEL_HEIGHT-m_halfheight);
	}
};
void CVObject::Draw(Sprites* _Sprite){
	if(m_pSprite)
		DrawSprite(m_pSprite,0,m_pos);
};